/**
 * 
 */
package jvs.peer.sec;

import java.io.Serializable;
import java.security.Principal;

/**
 * @author qiangli
 *
 */
public class User implements Serializable, Principal, Comparable<User> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	protected long connectionTime;
	protected long lastAccess;
	protected String name;
	protected String id;
	protected String resource;
	/**
	 * 
	 */
	public User() {
	}

	public User(String id, String name) {
		super();
		this.id = id;
		this.name = name;
	}

	public User(String id, String name, String resource) {
		super();
		this.id = id;
		this.name = name;
		this.resource = resource;
	}
	public User(String id) {
		this.id = id;
		this.name = id;
	}

	public long getConnectionTime() {
		return connectionTime;
	}

	public long getLastAccess() {
		return lastAccess;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setConnectionTime(long connectionTime) {
		this.connectionTime = connectionTime;
	}

	public void setLastAccess(long lastAccess) {
		this.lastAccess = lastAccess;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	public String getPeer() {
		return id +"/" + resource;
	}

	public int compareTo(User that) {
		return this.id.compareTo(that.id);
	}
}
